|
ARD2
RC2
Airbag Reference Demonstrator using MPC5604P
|
00001 /****************************************************************************/ 00045 #include "derivative.h" 00046 #include "Compile_Options.h" 00047 #include "main.h" 00048 #include "HAL.h" 00049 #include "SM.h" 00050 #include "Labview.h" 00051 /* 00052 ****************************************************************************** 00053 * Constants 00054 ****************************************************************************** 00055 */ 00057 static const uint8_t cau8ARD2FmwRev[] = ARD2_FIRMWARE_REV; 00058 /* 00059 ****************************************************************************** 00060 * Globals 00061 ****************************************************************************** 00062 */ 00063 /* 00064 ****************************************************************************** 00065 * main 00066 ****************************************************************************** 00067 */ 00068 void main(void) 00069 { 00070 /* Local variables */ 00071 uint8_t u8Status; 00072 00073 /* Init local variables */ 00074 u8Status = CLEAR; 00075 00076 /* Configure MCU to allow interrupts, and to use the correct peripherals */ 00077 u8Status = u8fnMCUInit(); 00078 00079 /* Make sure that we only go on if the result of init is successful */ 00080 vfnVerifyInitStatus(u8Status); 00081 00082 #ifdef DEBUGGING_NOW 00083 /* If we are debugging code, it's easier to stop PIT whenever we stop code */ 00084 PIT.PITMCR.B.FRZ = TRUE; 00085 #endif 00086 #ifdef USE_LABVIEW 00087 /* Transmit Firmware version to visual interface twice; First time to */ 00088 /* clear any existing message, second one to display actual message. */ 00089 (void)u8fnLabViewSendMSorMP((uint8_t*)cau8ARD2FmwRev, 00090 sizeof(cau8ARD2FmwRev), 00091 LV_SEND_SERIALLY, 00092 LV_MS_MSG); 00093 (void)u8fnLabViewSendMSorMP((uint8_t*)cau8ARD2FmwRev, 00094 sizeof(cau8ARD2FmwRev), 00095 LV_SEND_SERIALLY, 00096 LV_MS_MSG); 00097 DELAY_MSEC(1u); 00098 00099 #endif 00100 /* Enter main loop */ 00101 (void)u32fnSMLaunch(); 00102 00103 for (;;) 00104 { 00105 /* Safety net - never go out of here */ 00106 } 00107 } /* End main */ 00108 /* 00109 ****************************************************************************** 00110 * vfnVerifyInitStatus 00111 ****************************************************************************** 00112 */ 00113 void vfnVerifyInitStatus(uint8_t u8Status) 00114 { 00115 /* Flag via LEDs to describe result */ 00116 if(PERIPHERALS_NOT_INITIALIZED == u8Status) 00117 { 00118 #ifdef USE_GENERIC_EVB_BOARD 00119 vfnToggleOutputPin(LED1,! u8fnReadPin(LED1)); 00120 #endif 00121 #ifdef USE_ARD2_V1 00122 vfnToggleOutputPin(LED1,! u8fnReadPin(LED1)); 00123 #endif 00124 for(;;) 00125 { 00126 /* Nothing */ 00127 } 00128 } 00129 else if(DEFAULT_OPERATION_MODES_NOT_LOADED == u8Status) 00130 { 00131 #ifdef USE_GENERIC_EVB_BOARD 00132 vfnToggleOutputPin(LED1, !u8fnReadPin(LED2)); 00133 #endif 00134 #ifdef USE_ARD2_V1 00135 vfnToggleOutputPin(LED1, !u8fnReadPin(LED1)); 00136 vfnToggleOutputPin(LED2, !u8fnReadPin(LED2)); 00137 #endif 00138 for(;;) 00139 { 00140 /* Nothing */ 00141 } 00142 } 00143 else if(SWT_NOT_INITIALIZED == u8Status) 00144 { 00145 #ifdef USE_GENERIC_EVB_BOARD 00146 vfnToggleOutputPin(LED1, !u8fnReadPin(LED3)); 00147 #endif 00148 #ifdef USE_ARD2_V1 00149 vfnToggleOutputPin(LED3, !u8fnReadPin(LED3)); 00150 #endif 00151 for(;;) 00152 { 00153 /* Nothing */ 00154 } 00155 } 00156 else if(RUN_MODE_NOT_STARTED == u8Status) 00157 { 00158 #ifdef USE_GENERIC_EVB_BOARD 00159 vfnToggleOutputPin(LED1, !u8fnReadPin(LED4)); 00160 #endif 00161 #ifdef USE_ARD2_V1 00162 vfnToggleOutputPin(LED1, !u8fnReadPin(LED1)); 00163 vfnToggleOutputPin(LED3, !u8fnReadPin(LED3)); 00164 #endif 00165 for(;;) 00166 { 00167 /* Nothing */ 00168 } 00169 } 00170 else 00171 { 00172 #ifdef USE_GENERIC_EVB_BOARD 00173 vfnToggleOutputPin(LED1, !u8fnReadPin(LED1)); 00174 vfnToggleOutputPin(LED2, !u8fnReadPin(LED2)); 00175 vfnToggleOutputPin(LED3, !u8fnReadPin(LED3)); 00176 vfnToggleOutputPin(LED4, !u8fnReadPin(LED4)); 00177 #endif 00178 } 00179 return; 00180 } 00181 /* 00182 ****************************************************************************** 00183 * 00184 * End of file. 00185 * 00186 ****************************************************************************** 00187 */